# 管理员类继承用户类 有自己的相关属性级别level
from User import *


class Admin(User):
    def __init__(self, level):
        self._level = level

    @property
    def level(self):
        return self._level

    @level.setter
    def level(self, value):
        if not isinstance(value, str):
            raise ValueError("级别必须是字符串")
        self._level = value

    # 重写父类方法
    def toString(self):
        return "用户姓名:" + self.name + '\n用户性别:' + self.sex + '\n用户年龄:' + self.age + '\n用户电话:' + self.phone + '\n用户地址:' + self.address + '\n用户级别' + self.level


ad = Admin(object)
ad.name = '男'
ad.level = '123'
# ad.sex = 123

print(ad.name)
print(ad.level)
# print(ad.sex)
